package com.lishe.lishe.lishe.module.shopingcart.bean;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by shino on 2017/12/28.
 */

public class ShoppingCartObject implements Serializable {
    //购物车下的所有店铺
    @SerializedName("shopInfo")
    private List<StoreObject> storeObjects = new ArrayList<>();

    //购物车下总金额
    @SerializedName("totalPrice")
    private double totalPrice;

    private int checkGoodsCount = 0;//选中商品数

    //总支付金额
    private double payMoney;
    //全选
    private boolean isCheck = false;

    public List<StoreObject> getStoreObjects() {
        return storeObjects;
    }

    public void setStoreObjects(List<StoreObject> storeObjects) {
        this.storeObjects = storeObjects;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    public void setPayMoney(double payMoney) {
        this.payMoney = payMoney;
    }

    public double getPayMoney() {
        payMoney = 0;
        for (StoreObject businessObject : storeObjects) {
            for (GoodObject goodObject : businessObject.getGoodObjects()) {
                if (goodObject.isCheck()) {
                    payMoney = payMoney +  Integer.parseInt(goodObject.getPrice()) * goodObject.getQuantity();
                }
            }
        }
        return payMoney;
    }

    public int getCheckGoodsCount() {

        checkGoodsCount = 0;
        for (StoreObject storeObject : storeObjects) {
            for (GoodObject goodObject : storeObject.getGoodObjects()) {
                if (goodObject.isCheck()) {
                    checkGoodsCount = checkGoodsCount + 1;
                }
            }
        }


        return checkGoodsCount;
    }

    public void setCheckGoodsCount(int checkGoodsCount) {
        this.checkGoodsCount = checkGoodsCount;
    }
}
